Completed
Pull Request — develop (#111)
by Xaver
01:04
created

module.exports   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 24
rs 8.9713
nop 0
1
module.exports = function (gulp, plugins, config) {
2
  const fs = require('fs');
3
  return function htmlmin() {
4
    return gulp.src(config.build + '/*.html')
5
      .pipe(plugins.inject(gulp.src(['config.json']), {
6
        starttag: '<!-- inject:config -->',
7
        transform: function (filePath, file) {
8
          return '<script>var jsonData =' +
9
            file.contents.toString('utf8')
10
              .replace('<!-- inject:cache-breaker -->',
11
                Math.random().toString(12).substring(7)) +
12
            ';</script>'
13
            ;
14
        }
15
      }))
16
      .pipe(plugins.realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(config.faviconData)).favicon.html_code))
17
      .pipe(plugins.cacheBust({
18
        type: 'timestamp'
19
      }))
20
      .pipe(plugins.htmlmin({
21
        removeComments: true,
22
        collapseWhitespace: true,
23
        minifyJS: true
24
      }))
25
      .pipe(gulp.dest(config.build));
26
  };
27
};
28